import { Component, Input   } from '@angular/core';
// import { config } from '../../global/config';

/**
 * Generated class for the PercentageCircleComponent component.
 *
 * See https://angular.io/api/core/Component for more info on Angular
 * Components.
 */
@Component({
  selector: 'percentage-circle',
  templateUrl: 'percentage-circle.html'
})
export class PercentageCircleComponent {

  @Input()
  set percentage(percentage) {// 百分比，80%直接传入80即可
    this._percentage = percentage;
    this.configProgress();
  };
  @Input() progressWidth = 3;// 进度条宽度
  @Input() pathwayColor = "#eeeeee";// 轨道颜色
  @Input() progressColor = "#F75F47";// 进度条颜色
  private _percentage = 0;
  private rightCircleTransform;
  private leftCircleTransform;

  constructor() {}

  configProgress() {
    if (this._percentage < 50) {
      let num = this._percentage*3.6
      this.rightCircleTransform =  "rotate(" + (num - 135) + "deg)"
      this.leftCircleTransform =  "rotate(-135deg)"
    } else {
      let num = (this._percentage-50)*3.6
      this.rightCircleTransform =  "rotate(45deg)"
      this.leftCircleTransform =  "rotate(" + (num - 135) + "deg)"
    }
  }

}
